package com.IO;

import java.util.LinkedList;
import java.util.List;

/**
 * IO输出
 */
public class IOSystem {
    public static List<DCT> dcts = new LinkedList<>();

    public IOSystem() {
        DCT dct1 = new DCT();
        DCT dct2 = new DCT();
        DCT dct3 = new DCT();
        DCT dct4 = new DCT();
        // 初始化四个外围设备
        dct1.setName("keyboard");
        dct2.setName("mouse");
        dct3.setName("printer");
        dct4.setName("monitor");
        dcts.add(dct1);
        dcts.add(dct2);
        dcts.add(dct3);
        dcts.add(dct4);
    }

    public void showIOSystem() {

        System.out.println("设备控制表：");
        System.out.println("名称\t\t占用进程\t\t等待队列\t\t父节点名称");
        for (int i = 0; i < dcts.size(); i++) {
            if(dcts.get(i).getProcess()!=null) {
                System.out.println(dcts.get(i).getName() + "\t\t" + dcts.get(i).getProcess().getName()
                        + "\t\t" + dcts.get(i).showWaitingList() );
            }
        }
        System.out.println();
    }
}
